Skip validations in the oauth migration

Also enforced the presence of needed attributes of the services table on
the database level

Dominik Sander преди 10 години
родител
ревизия
b089919490
променени са 3 файла, в които са добавени 5 реда и са изтрити 6 реда
  1. 0 1
      app/concerns/oauthable.rb
  2. 4 4
      db/migrate/20140515211100_create_services.rb
  3. 1 1
      db/migrate/20140525150140_migrate_agents_to_service_authentication.rb

+ 0 - 1
app/concerns/oauthable.rb

@@ -4,7 +4,6 @@ module Oauthable
4 4
   included do |base|
5 5
     attr_accessible :service_id
6 6
     validates_presence_of :service_id
7
-    base.extend ClassMethods
8 7
     self.class_variable_set(:@@valid_oauth_providers, :all)
9 8
   end
10 9
 

+ 4 - 4
db/migrate/20140515211100_create_services.rb

@@ -1,10 +1,10 @@
1 1
 class CreateServices < ActiveRecord::Migration
2 2
   def change
3 3
     create_table :services do |t|
4
-      t.integer :user_id
5
-      t.string :provider
6
-      t.string :name
7
-      t.text :token
4
+      t.integer :user_id, null: false
5
+      t.string :provider, null: false
6
+      t.string :name, null: false
7
+      t.text :token, null: false
8 8
       t.text :secret
9 9
       t.text :refresh_token
10 10
       t.datetime :expires_at

+ 1 - 1
db/migrate/20140525150140_migrate_agents_to_service_authentication.rb

@@ -24,7 +24,7 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration
24 24
         secret: twitter_oauth_token_secret(agent)
25 25
       )
26 26
       agent.service_id = service.id
27
-      agent.save!
27
+      agent.save!(validate: false)
28 28
     end
29 29
     if agents.length > 0
30 30
       puts <<-EOF.strip_heredoc